using Godot;
using System;
using CurrentGame.NPC;
using CurrentGame.GUI.PlaceGrid;

namespace CurrentGame.Levels.EzEnd;

public partial class EzEndMain : Node
{
    private SceneSwitch _sceneSwitch;
    private PlaceModeGrid _placeGrid;
    private CinematicCamera _camera;
    private Player _player;
    private GameProgressManager _manager;

    public override void _Ready()
    {
        var map = GetNode<NodeReferenceMap>(Constants.NodeRefMapPath);
        _sceneSwitch = map.SceneSwitch;
        _sceneSwitch.SceneStart += Signal_SceneStart;
        _placeGrid = map.PlacementModeGrid;
        _player = map.MainPlayer;
        _camera = map.GameCamera;
        _manager = map.ProgressManager;

        _camera.SetBackgroundColor(0.14f);

        _player.SetHealthPoint(3);
        _player.DisablePlaceMode();
        _player.AttackEnabled = false;
        _player.PlaceModeAvailable = false;
    }

    public override void _ExitTree()
    {
        _sceneSwitch.SceneStart -= Signal_SceneStart;
        _placeGrid.ClearAllShade();
    }

    private void Signal_SceneStart()
    {
        GD.Print("Started EZ End");
    }

    private void Signal_EnterHard(Area2D area)
    {
        _manager.HardMode = true;
    }
}
